Carbon dioxide (CO2)#

Databases used:

  • Atmospheric C02 from the Muana Loa Observatory (ESRL at NOAA)

  • Oceanic values from the Hawaii Ocean Time-series (HOT)

import os

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import scipy.stats as sp

import sys
sys.path.append("../../../functions")
from data_downloaders import download_HOT_CO2_data, download_MLO_CO2_data

sys.path.append("../../../../indicators_setup")
from ind_setup.plotting import plot_timeseries
from ind_setup.plotting_int import plot_timeseries_interactive
from ind_setup.tables import plot_df_table

Observations from NOAA#

url = 'https://gml.noaa.gov/webdata/ccgg/trends/co2/co2_mm_mlo.txt'
MLO_data = download_MLO_CO2_data(url)

Observations from U.Hawaii#

Plotting#

Muana Loa Observatory

dict_plot = [{'data' : MLO_data, 'var' : 'CO2', 'ax' : 1, 'label' : 'MLO: CO2'},]
MLO_data['CO2_deseasoned'] = MLO_data['CO2'].rolling(window=12, center=True).mean()
dict_plot = [{'data' : MLO_data, 'var' : 'CO2', 'ax' : 1, 'label' : 'MLO: CO2'},
             {'data' : MLO_data, 'var' : 'CO2_deseasoned', 'ax' : 1, 'label' : 'MLO: CO2 (Deseasoned)'}]
plot_timeseries_interactive(dict_plot, trendline = False, figsize = (20, 12));
plot_timeseries_interactive(dict_plot, trendline = True, figsize = (20, 10));
from scipy.stats import linregress
MLOy = MLO_data[['CO2']].groupby(MLO_data.index.year).mean()
MLOy.index = pd.to_datetime(MLOy.index, format = '%Y')
slope, intercept, r_value, p_value, std_err = linregress(MLOy.index.year, MLOy['CO2'])

Annual Stats

d = MLOy.describe()
d.loc['Rate of change'] = slope
fig = plot_df_table(np.round(d, 2), figsize = (400, 400))
../../../_images/69445fd630d30895b147a1d8b903be80d14ee276eea979792d48f5371e08445d.png